<?php
class feedback_view extends SClass {

    public function process() {
            $checked=0;
            $user = $this->getUserSecure();
            if ($user) {
                if ($user->getLevel() >= 2) {
        	   $this->assign('autorized', 1);
                   $checked=1;

                    } 
              }
         try {
            if ($this->getControlValue('ok')) {

               
          	   ServiceUtils::GetFactory()->getFeedbackService()->addFeedback(
        	       $this->getControlValue('title'),
        	       $this->getControlValue('content'),
                       $this->getControlValue('name'),
                           $checked

        	   );
        	   $this->assign('message', 'ok');
            }
        } catch (ServiceUtils_Exception $e) {
            $this->assign('errors', $e->getErrors());
        }

        
        $post = ServiceUtils::GetFactory()->getFeedbackService()->getFeedbackChecked();
        $a = array();
        while ($x = $post->getNext()) {
            $a[] = array(
                'id' => $x->getId(),
                'title' => $x->getTitle(),
                'content' => $x->getContent(),
                'postdate' => $x->getPostdate(),
                'user' => $x->getName(),
                'urledit' => Engine_LinkMaker::GetURLByContentID(
                    'feedback_edit', $x->getId()),
                'urldelete' => Engine_LinkMaker::GetURLByContentID(
                    'feedback_del', $x->getId())
            );
        }
        $this->assign('postArray', $a);
    }

}